﻿using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace TMTemplate
{
	public partial class ImageButton : UserControl
	{
		public ImageButton()
		{
			InitializeComponent();
			VisualStateManager.GoToState(this, "Normal", false);
		}
		[System.ComponentModel.Category("Common Properties"), System.ComponentModel.Description("Gets or sets the image source")]
        public ImageSource ImageSource
        {
            get { return NewImage.Source; }
            set
            {
                if (DesignerProperties.IsInDesignTool || (value as BitmapImage).UriSource.ToString().Contains(";Component"))
                    NewImage.Source = value;
                else
                    NewImage.Source = new BitmapImage(new Uri("../"+(value as BitmapImage).UriSource.ToString(), UriKind.Relative));
            }
        }
    }
}